﻿namespace CSharpPro._1016;

public class Demo2
{
    public static void Test1()
    {
        int x = int.Parse(Console.ReadLine());
        int y = int.Parse(Console.ReadLine());
        int z = int.Parse(Console.ReadLine());
        int[] numbers = { x, y, z };
        Array.Sort(numbers);
        foreach (int num in numbers)
        {
            Console.Write(num + " ");
        }

        Console.WriteLine();
    }

    public static void Test2()
    {
        for (int i = 0; i < 100; i++)
        {
            int tens = (i / 10) % 10;
            int units = i % 10;
            if (i % 7 != 0 && tens != 7 && units != 7)
            {
                Console.WriteLine(i);
            }
        }
    }

    public static void Test3()
    {
        for (int i = 1; i < 10; i++)
        {
            for (int j = 1; j < 10; j++)
            {
                int sum = i * j;
                Console.WriteLine(i + "x" + j + "=" + sum);
            }
        }
    }

    public static void Test4()
    {
        Console.WriteLine("1000以内的完数有：");
        for (int num = 2; num <= 1000; num++)
        {
            if (IsPerfectNumber(num))
            {
                Console.Write(num + " ");
            }
        }

        static bool IsPerfectNumber(int num)
        {
            if (num <= 1)
                return false;

            int sum = 1;

            for (int i = 2; i <= num / 2; i++)
            {
                if (num % i == 0)
                {
                    sum += i;
                }
            }

            return sum == num;
        }
    }

    public static void Test5()
    {
        int num = int.Parse(Console.ReadLine());

        for (int i = 1; i <= 10; i++)
        {
            if (num < Math.Pow(10, i))
            {
                Console.WriteLine("这个数是" + i + "位数");
                break;
            }
        }

        int temp = 0;

        while (num > 0)
        {
            temp = temp * 10 + num % 10;
            num /= 10;
        }

        Console.WriteLine(temp);
    }

    public static void Test6()
    {
        Console.WriteLine("请输入菱形的行数：");
        int rows = int.Parse(Console.ReadLine());
        int half = rows / 2;

        for (int i = 0; i <= half; i++)
        {
            for (int j = 0; j < half - i; j++)
                Console.Write(" ");
            for (int k = 0; k < 2 * i + 1; k++)
                Console.Write("*");
            Console.WriteLine();
        }
        for (int i = half - 1; i >= 0; i--)
        {
            for (int j = 0; j < half - i; j++)
                Console.Write(" ");
            for (int k = 0; k < 2 * i + 1; k++)
                Console.Write("*");
            Console.WriteLine();
        }
    }
}


